package com.flx.at.spring.code.test.testbeanprocessor;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanPostProcessor;
import org.springframework.stereotype.Component;

/**
 * @Author: Fenglixiong
 * @Date: 2021/7/3 19:19
 * @Description:
 */
@Component
public class BeanProcessor implements BeanPostProcessor {

    /**
     * init方法之前调用
     * @param bean
     * @param beanName
     * @return
     * @throws BeansException
     */
    @Override
    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("BeanProcessBefore——>"+beanName);
        return bean;
    }

    /**
     * init方法之后调用
     * @param bean
     * @param beanName
     * @return
     * @throws BeansException
     */
    @Override
    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException {
        System.out.println("BeanProcessAfter——>"+beanName);
        return bean;
    }
}
